/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.article;

import java.util.ArrayList;
import model.generic.TableModelWithListeners;
import util.article.PriceDetails;

/**
 *
 * @author Dirk
 */
public class PriceTableModel extends TableModelWithListeners {
    
    private ArrayList<PriceDetails> prices;
    private static final String[] COLUMNS = {"Prijsklasse", "Maat", "Model", "Aankoopprijs","Korting", "Coëfficiënt","Prijs"};
    
    public PriceTableModel(){
        prices = new ArrayList<PriceDetails>();
    }

    @Override
    public void removeItem(int index) {
        
    }

    @Override
    public int getRowCount() {
        return prices.size() + 1;
    }

    @Override
    public int getColumnCount() {
        return COLUMNS.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        if(rowIndex < prices.size()){
            if(columnIndex == 0)
                return prices.get(rowIndex).getPriceClass().getName();
            else if(columnIndex == 1)
                return prices.get(rowIndex).getSize().getName();
            else if(columnIndex == 2)
                return prices.get(rowIndex).getModel().getCode();
            else if(columnIndex == 3)
                return prices.get(rowIndex).getPurchase();
            else if(columnIndex == 4)
               return prices.get(rowIndex).getDiscount();
            else if(columnIndex == 5)
                return prices.get(rowIndex).getCoefficient();
            else
                return prices.get(rowIndex).getPrice();
        } else {
            if(columnIndex == 0)
                return "Selecteer een prijsklasse";
            else if(columnIndex == 1)
                return "Selecteer een maat";
            else if(columnIndex == 2)
                return "Selecteer een model";
            else
                return "";
        }
    }

    @Override
    public String getColumnName(int column) {
        return COLUMNS[column];
    }
    
    
    
}
